<?php

namespace app\comm\service;
use app\mall\model\Goods;
use app\comm\model\GoodsComment;
use app\comm\model\GoodsMaterial;
use app\comm\model\GoodsYongliao;
use app\comm\model\User;
use app\comm\model\UserPointlog;
use app\comm\model\UserWalletlog;
use app\comm\model\Coupon;

use think\Db;
use ServS\DbShowcollo;
use app\comm\service\SysToolsLevePoint;
/**
 * youhui务层
 * 
 */
class MyYcardService{	

	/**
	 * 获取我的优惠券
	 * @param  [type] $uid [description]
	 * @return [type]      [description]
	 */
	public function getmycard($uid){
		$map=["uid"=>$uid,"is_used"=>0];
		$ycard = Db::table('ys_user_ycard')->alias('ycard')->where($map)->select();
		foreach ($ycard as $key => &$value) {
			 $value['coupon'] = Coupon::get($value['coupon_id'])->toArray();
		}
		return $ycard;
	}

	/**
	 * 优惠券
	 */
	public function findycard($id){
		$ycard = Db::table('ys_user_ycard')->find($id);
		return $ycard;
	}

	/**
	 * 设为已使用
	 */
	public function sentuse($id){
		return Db::table('ys_user_ycard')->where('id', $id)->update(['is_used' => 1]);
	}

	
}